package top.hudk.advantage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import top.hudk.advantage.entity.LoginResultEntity;
import top.hudk.advantage.service.LoginService;

import java.io.IOException;
import java.net.URISyntaxException;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public String login(String code) throws IOException, URISyntaxException {
        LoginResultEntity loginResultEntity = loginService.login(code);
        return loginResultEntity.getOpenid();
    }
}
